using Holoville.HOTween;
using Holoville.HOTween.Core;
using UnityEngine;

public class MyMiniTween : MonoBehaviour
{
	[SerializeField]
	private UIWidget widget;

	[SerializeField]
	private Vector3 endPosOffset = new Vector3(200f, 0f, 0f);

	private Vector3 startPos;

	[SerializeField]
	private float alphaDuration = 0.2f;

	[SerializeField]
	private float baseTransformDuration = 0.3f;

	[SerializeField]
	private float hideAfter = 3f;

	[SerializeField]
	private bool animateWhileWate = true;

	[SerializeField]
	private bool hideArterShow = true;

	[SerializeField]
	private float maxAlpha = 1f;

	[SerializeField]
	private float minAlpha;

	public void Awake()
	{
		if (widget == null)
		{
			widget = GetComponent<UIWidget>();
		}
		if (widget == null)
		{
			base.enabled = false;
			return;
		}
		startPos = widget.transform.localPosition;
		widget.transform.localPosition = startPos + endPosOffset;
	}

	private void Start()
	{
		widget.alpha = 0f;
	}

	public void Show(bool val)
	{
		HOTween.Kill(widget.transform);
		HOTween.To(widget, alphaDuration, new TweenParms().Prop("alpha", (!val) ? minAlpha : maxAlpha).UpdateType(UpdateType.TimeScaleIndependentUpdate));
		HOTween.To(widget.transform, baseTransformDuration, new TweenParms().Prop("localPosition", (!val) ? (startPos + endPosOffset) : startPos).UpdateType(UpdateType.TimeScaleIndependentUpdate).OnComplete((TweenDelegate.TweenCallback)delegate
		{
			if (!val)
			{
				widget.transform.localPosition = startPos + endPosOffset;
				widget.alpha = 0f;
			}
			else
			{
				if (animateWhileWate)
				{
					HOTween.To(widget.transform, 30f, new TweenParms().Prop("localPosition", startPos + endPosOffset));
				}
				if (hideArterShow)
				{
					CancelInvoke("Hide");
					Invoke("Hide", hideAfter);
				}
			}
		}));
	}

	public void Hide()
	{
		Show(false);
	}
}
